package com.acme.bankapp.domain.accounts;
/**
 * Represents an account with NO overdraft.
 * 
 * Holds balance info.
 * Ensures safety of business rules.
 *
 */
public class SavingsAccount extends AbstractAccount {

	/**
	 * Creates a Checking account with zero balance.
	 */
	public SavingsAccount() {
		balance = 0.;
	}

	/**
	 * Withdraws amount > 0. from account.
	 * @param amount amount to be withdrawn.
	 * @return true if amount is positive and amount is small enough to be withdrawn, false otherwise.
	 */
	public boolean withdraw(double amount) {
		if ((0. < amount) && (amount < balance)) {
			balance -= amount;
			return true;
		} 

		return false;
	}

	/**
	 * Adds amount > 0. to account's balance.
	 * @param amount amount to be deposited.
	 * @return true if amount positive, false otherwise.
	 */
	public boolean deposit(double amount) {
		if (0. < amount) {
			balance += amount;
			return true;
		}

		return false;
	}

	public double getBalance() {
		return balance;
	}

	/**
	 * Returns balance as String.
	 */
	@Override
	public String toString() {
		return "" + getBalance();
	}

}